﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListOfPersons
{
    class Program
    {
        static void Main(string[] args)
        {
            Random rnd = new Random();
            Console.Write("Введите количество случайных людей для вывода списка: ");
            int n = (int)ReadUintFromConsole();
            Person[] people = GeneratePersons(n, rnd);
            PrintArray(people);
            Console.ReadKey();
        }
        static Person GetRandomPerson(Random rnd)
        {
            String[] names = { "Евгений", "Николай", "Петр", "Антон", "Иван", "Алексей", "Александр" };
            String[] lastName = { "Иванов", "Петров", "Сидоров", "Жагин", "Максак", "Демидов" };
            DateTime[] days = { new DateTime(1990, 2, 1), new DateTime(1983, 2, 18), new DateTime(1981, 6, 12), new DateTime(1979, 3, 25) };
            Person p = new Person();
            p.FirstName = names[rnd.Next(0, names.Length)];
            p.LastName = lastName[rnd.Next(0, lastName.Length)];
            p.Dob = days[rnd.Next(0, days.Length)];
            return p;
        }
        static void PrintPerson(Person p)
        {
            Console.WriteLine("{1} {0}, дата рождения: {2}", p.FirstName, p.LastName, p.Dob.ToString("dd MMM yyyy"));
        }
        static Person[] GeneratePersons(int n, Random rnd)
        {
            Person[] people = new Person[n];
            Person p = null;
            for (int i = 0; i < n; i++)
            {
                p = GetRandomPerson(rnd);
                people[i] = p;
            }
            return people;
        }
        static void PrintArray(Person[] array)
        {
            for (int i = 0; i < array.Length; i++)
            {
                Person p = array[i];
                PrintPerson(p);
            }
        }
        static uint ReadUintFromConsole()
        {
            try
            {
                return (uint.Parse(Console.ReadLine()));
            }
            catch
            {
                Console.WriteLine("Input error");
                return ReadUintFromConsole();
            }
        }
    }
}
